
package memory;

import java.lang.management.ClassLoadingMXBean;
import java.lang.management.CompilationMXBean;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.util.List;

public class JvmInformation {
	private RuntimeMXBean mxbean;
	private MemoryMXBean mbean ;
	private CompilationMXBean cmxbean;
	private OperatingSystemMXBean osmxbean;
	private List <GarbageCollectorMXBean> gcmxbean;
	private ClassLoadingMXBean clmxbean;
	private String jvmVersion ;
	private String jvmVendor;	
	private long  usedHeapMemo;
	private long usedMaxHeapMemo;
	private long usedCommitedMemory;
	
	public JvmInformation() {
		mxbean = ManagementFactory.getRuntimeMXBean();
		mbean = ManagementFactory.getMemoryMXBean();
		cmxbean=ManagementFactory.getCompilationMXBean();
		osmxbean=ManagementFactory.getOperatingSystemMXBean();
		gcmxbean=ManagementFactory.getGarbageCollectorMXBeans();
		clmxbean=ManagementFactory.getClassLoadingMXBean();
		jvmVersion = mxbean.getVmVersion();
		jvmVendor =  mxbean.getVmVendor();
		usedHeapMemo = mbean.getHeapMemoryUsage().getUsed();
		usedMaxHeapMemo = mbean.getHeapMemoryUsage().getMax();
		usedCommitedMemory = mbean.getHeapMemoryUsage().getCommitted();
	}
	
	public List<GarbageCollectorMXBean> getGcmxbean(){
		return gcmxbean;
	}
	
	public RuntimeMXBean getMxbean(){
		return mxbean;
	}
	
	public MemoryMXBean getMbean(){
		return mbean;
	}
	
	public OperatingSystemMXBean getOsmxbean() {
		return osmxbean;
	}

	/*public ClassLoadingMXBean getGcmxbean() {
		return gcmxbean;
	}*/

	public CompilationMXBean getCmxbean(){
		return cmxbean;
	}
	
	public String getJvmVersion(){
		return jvmVersion ;
		
	}
	public String getJvmVendor(){
		return jvmVendor;
	}
	
    public long getUsedHeapMemo(){
        return usedHeapMemo;
    }
    
    public long getUsedMaxHeapMemo(){
       return usedMaxHeapMemo;
    }
    
    public long getUsedCommitedMemo(){
        return usedCommitedMemory;
    }

	public ClassLoadingMXBean getClmxbean() {
		return clmxbean;
	}

	public void setClmxbean(ClassLoadingMXBean clmxbean) {
		this.clmxbean = clmxbean;
	}	
 
}
